<template>
	<view class="page-index">
		<uni-forms ref="form" :modelValue="form" :rules="rules" err-show-type="undertext">
			<uni-forms-item name="type">
				<view class="formBox">
					<view class="formTitle">
						订单类型
						<text style="color: #F00;;">*</text>
					</view>
					<view class="formValue"><uni-data-select v-model="value" :localdata="range" @change="typeChange"></uni-data-select></view>
				</view>
				<view class="formTips">
					<view class="formEpt"></view>
					<view class="formValues">{{ tips }}</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="shop_name">
				<view class="formBox">
					<view class="formTitle">
						施工门店
						<text style="color: #F00;;">*</text>
					</view>
					<view class="formValue">
						<view class="formSelect">{{ shopData.name ? shopData.name : '请添加门店' }}</view>
					</view>
				</view>
				<view class="formTips">
					<view class="formEpt"></view>
					<view class="formAdd" @click="jump('/pages/user/myStore/index')">+添加新门店</view>
				</view>
			</uni-forms-item>

			<uni-forms-item name="part_type">
				<view class="formBox" style="margin-top: 0;">
					<view class="formTitle">
						施工部位
						<text style="color: #F00;;">*</text>
					</view>
					<view class="formValue"><uni-data-checkbox v-model="form.part_type" :localdata="sex" @change="partChange"></uni-data-checkbox></view>
				</view>
				<view class="formBox" v-if="form.part_type == 'part'">
					<view class="formTitle">局部施工部位</view>
					<view class="formValue">
						<view class="formSelect" @click="this.$refs.part.open('bottom')">{{ partName.length > 0 ? partName.join() : '请选择局部施工部位' }}</view>
					</view>
				</view>
				<view class="formTips" v-if="form.part_type == 'all'">
					<view class="formEpt"></view>
					<view class="formValues" style="color: #000;">{{ ps.part_info != null ? ps.part_info : '' }}</view>
				</view>
			</uni-forms-item>
			<uni-forms-item name="second">
				<view class="formBox" @click="chooseCar()" style="margin-top: 0;">
					<view class="formTitle">
						施工车型
						<text style="color: #F00;;">*</text>
					</view>
					<view class="formValue">
						<view class="formSelect">{{ form.car_model ? form.car_model : '请选择车型' }}</view>
						</view>
			</view>
			</uni-forms-item>
			<view class="formBox">
				<view class="formTitle">
					漆面是否有损伤
					<text style="color: #F00;;">*</text>
				</view>
				<view class="formValue"><uni-data-checkbox v-model="form.is_damage" :localdata="sex1"></uni-data-checkbox></view>
			</view>
			<view class="formTips" v-if="form.is_damage == 1">
				<view class="formEpt"></view>
				<view class="formValues" style="color: #000;">{{ ps.remind }}</view>
			</view>
			<uni-forms-item name="work_time">
				<view class="formBox">
					<view class="formTitle">
						技师到店时间
						<text style="color: #F00;;">*</text>
					</view>
					<view class="formValue"><uni-datetime-picker type="datetime" v-model="form.work_time" hide-second :start="startTime" :end="endTime" /></view>
				</view>
			</uni-forms-item>
			<!-- 		<view class="formBox" v-if="use_coupon == 'yes' && coupon.id">
				<view class="formTitle">是否使用{{coupon.coupon_name}}抵扣{{coupon.coupon_price}}元</view>
				<view class="formValue"><switch :checked="form.use_coupon == 1 ? true : false" @change="switchChange" /></view>
			</view> -->
			<!-- <uni-forms-item name="work_time"> -->
			<view class="formBox" >
				<view class="formTitle">优惠券</view>
				<view class="formValue" @click="this.$tools.navigate('/pages/home/coupon/index?use_coupon=' + this.use_coupon)">
					<view class="formSelect">{{ form.my_coupon_id ? couponTitle : '暂不使用' }}</view>
				</view>
			</view>
			<!-- </uni-forms-item> -->
		</uni-forms>

		<uni-popup ref="car" type="bottom" @touchmove.stop.prevent="" v-if="listStatus">
			<view class="carBox"><uni-indexed-list :options="list" :showSelect="false" @click="carClick"></uni-indexed-list></view>
		</uni-popup>
		<uni-popup ref="carType" type="bottom" @touchmove.stop.prevent="">
			<view class="carBox">
				<scroll-view class="partBox" scroll-y>
					<view class="partItem" v-for="(item, index) in carTypeList" :key="index" @click="carTypeClick(item, index)">
						<view class="">{{ item.name }}</view>
						<!-- <uni-icons type="checkmarkempty" size="30" v-if="form.part_ids.indexOf(item.id)>-1"></uni-icons> -->
					</view>
				</scroll-view>
			</view>
		</uni-popup>
		<uni-popup ref="part" type="bottom" @touchmove.stop.prevent="">
			<scroll-view class="partBox" scroll-y>
				<view class="partItem" v-for="(item, index) in partList" :key="index" @click="partClick(item, index)">
					<view class="">{{ item.name }}</view>
					<uni-icons type="checkmarkempty" size="30" v-if="form.part_ids.indexOf(item.id) > -1"></uni-icons>
				</view>
			</scroll-view>
			<view class="close" @click="this.$refs.part.close()">确认</view>
		</uni-popup>
		<view class="submit" @click="submit()">提交</view>
	</view>
</template>

<script src="./page.js"></script>

<style scoped lang="scss">
@import 'page.scss';
</style>
